home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 14 / hacker14.iso / programacao / visual / perl.exe / {app} / Webroot / cgi-bin / frameset.cgi < prev    next >
Encoding:
Text File  |  2003-01-11  |  2.1 KB  |  82 lines

  1. #!perl
  2.  
  3. use CGI;
  4.  
  5. $query = new CGI;
  6. print $query->header;
  7. $TITLE="Frameset Example";
  8.  
  9. # We use the path information to distinguish between calls
  10. # to the script to:
  11. # (1) create the frameset
  12. # (2) create the query form
  13. # (3) create the query response
  14.  
  15. $path_info = $query->path_info;
  16.  
  17. # If no path information is provided, then we create
  18. # a side-by-side frame set
  19. if (!$path_info) {
  20.     &print_frameset;
  21.     exit 0;
  22. }
  23.  
  24. # If we get here, then we either create the query form
  25. # or we create the response.
  26. &print_html_header;
  27. &print_query if $path_info=~/query/;
  28. &print_response if $path_info=~/response/;
  29. &print_end;
  30.  
  31.  
  32. # Create the frameset
  33. sub print_frameset {
  34.     $script_name = $query->script_name;
  35.     print <<EOF;
  36. <html><head><title>$TITLE</title></head>
  37. <frameset cols="50,50">
  38. <frame src="$script_name/query" name="query">
  39. <frame src="$script_name/response" name="response">
  40. </frameset>
  41. EOF
  42.     ;
  43.     exit 0;
  44. }
  45.  
  46. sub print_html_header {
  47.     print $query->start_html($TITLE);
  48. }
  49.  
  50. sub print_end {
  51.     print qq{<P><hr><A HREF="../index.html" TARGET="_top">More Examples</A>};
  52.     print $query->end_html;
  53. }
  54.  
  55. sub print_query {
  56.     $script_name = $query->script_name;
  57.     print "<H1>Frameset Query</H1>\n";
  58.     print $query->startform(-action=>"$script_name/response",-TARGET=>"response");
  59.     print "What's your name? ",$query->textfield('name');
  60.     print "<P>What's the combination?<P>",
  61.     $query->checkbox_group(-name=>'words',
  62.                                -values=>['eenie','meenie','minie','moe']);
  63.  
  64.     print "<P>What's your favorite color? ",
  65.     $query->popup_menu(-name=>'color',
  66.                        -values=>['red','green','blue','chartreuse']),
  67.     "<P>";
  68.     print $query->submit;
  69.     print $query->endform;
  70. }
  71.  
  72.  
  73. sub print_response {
  74.     print "<H1>Frameset Result</H1>\n";
  75.     unless ($query->param) {
  76.         print "<b>No query submitted yet.</b>";
  77.         return;
  78.     }
  79.     print "Your name is <EM>",$query->param(name),"</EM>\n";
  80.     print "<P>The keywords are: <EM>",join(", ",$query->param(words)),"</EM>\n";
  81.     print "<P>Your favorite color is <EM>",$query->param(color),"</EM>\n";
  82. }